<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //可变长参数的使用
        //需求：求出给定数值序列的和
        function sum(...nums){
            let sum = 0;
            for(let i = 0; i < nums.length; i++){
                sum = sum + nums[i];
            }
            return sum;
            }
        //调用
        console.log(sum(1,2,3,4,5));
        console.log(sum(11,22,33,44,55,66,77,88,99));
    </script>
</body>
</html>